#include <bits/stdc++.h>
#define int long long 
using namespace std;

int func(int n) {
    int mod = n % 4;
    if (mod == 0) return n;
    if (mod == 1) return 1;
    if (mod == 2) return n + 1;
    return 0;
}

signed main() {
    int n, m;
    cin >> n >> m;
    int S = func(n);
    int T = func(n + m) ^ func(n);
    if (S != T) {
        cout << -1;
        return 0;
    }
    vector<vector<int>> M(n, vector<int>(m));
    for (int i = 0; i < n-1; ++i)
        M[i][m-1] = i+1;
    for (int j = 0; j < m-1; ++j)
        M[n-1][j] = n+1+j;
    M[n-1][m-1] = (n + m) ^ func(n-1);
    for (auto& row : M) {
        for (int x : row) cout << x << ' ';
        cout << endl;
    }
}
